package collection;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 将集合元素转换类型
 */
public class StreamAPIDemo5 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(i);
        }
        System.out.println(list);

        List<Double> list2 = list.stream().mapToDouble(e->e/2)
                             .boxed()//转换是需要包装，否则流原本元素类型还是Integer
                             .collect(Collectors.toList());
        System.out.println(list2);
    }
}




